
from meta_service.store import ArxivPaper
from meta_service.ucentre import AnyTag
from meta_service.ucentre import ARXIVTYPEID

class ArxivTag(AnyTag):

    def __init__(self, entry_id) -> None:
        super().__init__(entry_id)
    
    def check(self):
        pass

def make_date_tag(paper: ArxivPaper):
    if paper.get_id_type() == ARXIVTYPEID:
        tag = ArxivTag(paper.get_entry_id())
        if tag.HasTag("year"):
            return tag
        entry_id = paper.get_entry_id()
        header = entry_id.split(".")[0]
        year = "unkown"
        month = "unkown"
        if len(header) == 4:
            year = "20" + str(header[:2])
            month = str(header[2:])
        tag.AddTag("year",year)
        tag.AddTag("month",month)
        return tag
    return None

def InitArxivTag(paper: ArxivPaper) -> ArxivTag:
    return make_date_tag(paper)

def GetArxivTag(paper: ArxivPaper) -> ArxivTag:
    return make_date_tag(paper)
